package cauc;

import Protocol.DownlinkProtocol;

public class ConnectionClient {
    public boolean isClosed;

    private ConnectionThread connectionThread;

    public ConnectionClient(String IP, String port, MainForm mainForm){
        connectionThread = new ConnectionThread(IP, port, mainForm);
        new Thread(connectionThread).start();
    }

    public void addNewRequest(DownlinkProtocol protocol){
        if(connectionThread != null && !isClosed){
            connectionThread.addRequest(protocol);
        }
    }

    public void closeConnection(){
        isClosed = true;
        connectionThread.stop();
    }
}
